#定义银行的数据库（当前三个用户）
user_list = [
	{"name":"AA","money":101,"password":"123456"},
	{"name":"BB","money":202,"password":"123445"},
	{"name":"CC","money":303,"password":"123451"}
]

#定义检验账户的函数
def login():
	global flag
	global money
	for i in user_list:
		if username==i["name"]:
			if userpassword==i["password"]:
				print(i['name'],"欢迎使用！")
				money = i["money"]
				flag = True

#定义查询余额函数
def showMoney():
	print('|{0:<12}|{1:<8}|'.format('name','money'))
	print('-'*15)
	print('|{0:<12}|{1:<8}|'.format(username,money))

#定义存款的函数
def savemoney():
	global money
	showMoney()
	print("存款金额")
	addmoney = int(input())
	money = money+addmoney
	showMoney()

#定义取款的函数
def getmoney():
	global money
	showMoney()
	print("取款金额")
	outmoney = int(input())
	money = money-outmoney
	showMoney()

#定义主界面的函数
def show():
	global flag
	login()
	while flag:
		print('='*10,'银行存取款系统','='*10)
		print('{0:1} {1:13} {2:14}'.format(' ','1.余额','2.存款'))
		print('{0:1} {1:15} {2:14}'.format(' ','3.取款','4.退出'))
		key=int(input('请输入对应选择：'))

		if key==1:
			print('查询余额：')
			showMoney()
			input('继续')
		elif key==2:
			print('存款：')
			savemoney()
			input('继续')
		elif key==3:
			print('取款')
			getmoney()
			input('继续')
		elif key==4:
			print('退出')
			break
		else:
			print('输入错误')
	else:
		print("用户名或密码错误")

#登陆界面
print("请输入用户名：")
username = input()
print("请输入密码：")
userpassword = input()
flag = False
show()